package barinadroid.game;

import org.andengine.entity.primitive.Rectangle;
import org.andengine.extension.physics.box2d.PhysicsConnector;
import org.andengine.extension.physics.box2d.PhysicsFactory;
import org.andengine.extension.physics.box2d.PhysicsWorld;
import org.andengine.util.color.Color;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;

public class Wall extends GameEntity
{
	private PhysicsWorld physicsWorld;

	public Wall(Vector2 location, Vector2 size, PhysicsWorld physicsWorld)
	{
		this.physicsWorld = physicsWorld;
		this.sprite = new Rectangle(location.x, location.y, size.x, size.y, GameActivity.getSharedInstance().getVertexBufferObjectManager());
		this.sprite.setRotationCenter(sprite.getWidth() * .5f, sprite.getHeight() * .5f);
		this.sprite.setColor(Color.BLACK);
		this.sprite.setAlpha(.2f);
		setBody(EntityIdentity.GENERAL);
		this.reset();
	}

	@Override
	void setBody(EntityIdentity identity)
	{
		this.body = PhysicsFactory.createBoxBody(physicsWorld, sprite, BodyType.StaticBody, identity.getFixtureDef());
		this.body.setUserData(this);
		setEntityIdentity(identity);
		physicsWorld.registerPhysicsConnector(new PhysicsConnector(this.sprite, this.body, true, true));
	}
}